{extend name="main"}
{block name="style"}
<style type="text/css">
	.flex-lable{width: 100px;color: #6c757d;text-align: right;padding-right: 10px;}
	.el-progress-bar__inner{text-align: center;}
	.text-2d91f0{color: #2d91f0;}
</style>
{/block}
{block name="body"}
<div class="bg-white mb-3">
	<el-form :model="search" @submit.native.prevent="submitForm" ref="search" label-position="right" class="flex py-3">

	  <el-form-item label="搜索类型" prop="search_type" class="flex mb-0 pl-3">
	  	<el-select v-model="search.search_type" placeholder="请选择" class="w-100px">
		    <el-option key="id"label="简历ID"value="id"></el-option>
		    <el-option key="uid"label="UID"value="uid"></el-option>
		    <el-option key="name"label="姓名"value="name"></el-option>
		    <el-option key="mobile"label="手机号"value="mobile"></el-option>
		    <el-option key="email"label="联系人邮箱"value="email"></el-option>
		</el-select>
	  </el-form-item>

	  <el-form-item label="审核" prop="examine" class="flex mb-0 pl-3">
	  	<el-select v-model="search.examine" placeholder="请选择" class="w-100px">
		    <el-option label="全部"value="all"></el-option>
		    <el-option label="未审核":value="0"></el-option>
		    <el-option label="已审核":value="1"></el-option>
		    <el-option label="驳回":value="2"></el-option>
		</el-select>
	  </el-form-item>

	  <el-form-item :label="getSearchType()" prop="key" class="flex mb-0 pl-3">
	    <el-input v-model="search.key" placeholder="请输入你想搜索的关键词"></el-input>
	  </el-form-item>

	  <el-form-item class="flex mb-0 pl-3">
	    <el-button type="primary" @click="initHtml">查询</el-button>
	    <el-button @click="resetForm('search')">重置</el-button>
	  </el-form-item>
	</el-form>
</div>
<div class="bg-white p-3">
	<div class="table-responsive">
		<el-table
			ref="tableList"
	      	:data="tableData"
    		v-loading="search.ajax"
    		style="width: 100%;"
    		header-cell-class-name="table-header-DDE6FB"
    		@selection-change="handleSelectionChange">
		  <el-table-column
			  type="selection"
			  width="55">
		  </el-table-column>
	      <el-table-column
	        prop="id"
	        label="ID"
	        width="100">
	      </el-table-column>
	      <el-table-column
	        label="姓名"
	        width="160">
		      <template slot-scope="scope">
		      	<div>
		      	<el-link type="primary" :href="'/resume/find/'+scope.row.id" target="_blank"
		      	:underline="false"
		      	title="浏览">{{scope.row.name}}</el-link>
		      	<div>{{scope.row.mobile}}</div>
		      	</div>
		      </template>
	      </el-table-column>
	      <el-table-column
	        label="基本信息"
	        min-width="380">
		      <template slot-scope="scope">
		      	<div class="small">
		      		<div class="flex text-nowrap flex-center font-weight-bold">
			        	<div>{{XYBase.Date.getMStoYear(scope.row.age*1000)}}岁</div>
		      			<div class="mx-1">·</div>
						<div v-if="scope.row.sex==1">男</div>
						<div v-else-if="scope.row.sex==2">女</div>
						<div v-else="scope.row.sex">未设置</div>
		      			<div class="mx-1">·</div>
			        	<div>{{scope.row.educational_background}}</div>
		      			<div class="mx-1">·</div>
			        	<div>{{XYBase.Date.getMStoYear(scope.row.work_experience_time*1000)}}年经验</div>
		      		</div>
		      		<div class="flex text-nowrap flex-center" v-for="v in scope.row.ResumeEmploymentIntention">
		      			<div class="text-2d91f0">{{v.jobs_cate3}}</div>
		      			<div class="border-left py-1 mx-1"></div>
		      			<div>{{v.industry?v.industry:'行业不限'}}</div>
		      			<div class="border-left py-1 mx-1"></div>
		      			<div v-if="v.area_city">{{v.area_city}}{{v.area_area}}</div>
		      			<div v-else>地区不限</div>
		      			<div class="border-left py-1 mx-1"></div>
		      			<div v-if="v.salary_min>0">{{v.salary_min}}~{{v.salary_max}}k</div>
		      			<div v-else>面议</div>
		      		</div>
		      	</div>
		      </template>
	      </el-table-column>
	      <el-table-column
	        label="完整度"
	        width="200">
		      <template slot-scope="scope">
		      	<div class="pr-5">
		      	<el-progress :percentage="scope.row.progress" :text-inside="true" :stroke-width="16" color="#2d91f0"></el-progress>
		      	</div>
		      </template>
	      </el-table-column>
	      <el-table-column
	        label="求职状态/浏览"
	        width="260">
		      <template slot-scope="scope">
		      <div class="small">
		      	<div>求职状态：{{scope.row.job_status}}</div>
		      	<div>来源：{{scope.row.app_name}}</div>
		      </div>
		      </template>
	      </el-table-column>
	      <el-table-column
	        label="审核/状态"
	        width="120">
		      <template slot-scope="scope">
		      	<div>
				<div class="mb-1">
		      	<transition>
		      		<el-button type="success" size="minism"
		      		v-if="scope.row.examine==1 || scope.row.examine=='loading'"
		      		:loading="scope.row.examine=='loading'">已审核</el-button>
		      		<el-button type="info" size="minism" 
		      		v-else-if="scope.row.examine==0 || scope.row.examine=='loading'" 
		      		:loading="scope.row.examine=='loading'">待审核</el-button>
		      		<el-button type="danger" size="minism" 
		      		v-else-if="scope.row.examine==2 || scope.row.examine=='loading'" 
		      		:loading="scope.row.examine=='loading'">未通过</el-button>
				</transition>
				</div>
				<div>
		      	<transition>
		      		<el-button type="success" size="minism"
		      		v-if="scope.row.privacy==1">展示中</el-button>
		      		<el-button type="info" size="minism" 
		      		v-else="scope.row.privacy==0" >未展示</el-button>
				</transition>
				</div>
				</div>
		      </template>
	      </el-table-column>
	      <el-table-column
	        label="创建/更新/刷新时间"
	        width="180">
		      <template slot-scope="scope">
		      	<div class="small">
		          <div>{{ scope.row.create_time }}</div>
		          <div>{{ scope.row.update_time }}</div>
		          <div>{{ scope.row.refresh_time }}</div>
		      	</div>
		      </template>
	      </el-table-column>
	      <el-table-column
	        label="/"
	        width="160">
		      <template slot-scope="scope">
		        <el-button
		            type="success"
		            plain
		            round
		            size="minism"
		            @click="setResumeDelete(scope)">
		            恢复
		        </el-button>
		        <el-button
		            type="danger"
		            plain
		            round
		            size="minism"
		            @click="setResumeDeleteForce(scope)">
		            彻底删除
		        </el-button>
		      </template>
	      </el-table-column>
	    </el-table>
	</div>
	<div class="table-responsive py-3 text-center">
		<el-pagination
		  background
	      @size-change="handleSizeChange"
	      @current-change="handleCurrentChange"
	      :current-page="search.page"
	      :page-sizes="[10,50,100,200]"
	      :page-size="search.pageSize"
	      layout="total, sizes, prev, pager, next, jumper"
	      :total="search.total">
	    </el-pagination>
	</div>
</div>
{/block}
{block name="script"}
<script type="text/javascript">
	{empty name="admin"}
	var admin=[];
	{else/}
	var admin={:json_encode($admin,JSON_UNESCAPED_UNICODE)};
	{/empty}
</script>
<script type="text/javascript">
	var vm=new Vue({
		el:'#app',
		data:{
			view:XYBase.view,
			labelPosition:'right',
			multipleSelection:[],
			showLog:false,
			drawerHandle:false,
			drawerHandleFind:{},
			admin:admin,
			adviser:{id:0},
			search:{
				{notempty name=":request()->get('resume_id')"}
				search_type:'id',
				key:'{:request()->get('resume_id')}',
				{elseif request()->get('uid')/}
				search_type:'uid',
				key:'{:request()->get('uid')}',
				{elseif request()->get('name')/}
				search_type:'name',
				key:'{:request()->get('name')}',
				{elseif request()->get('mobile')/}
				search_type:'mobile',
				key:'{:request()->get('mobile')}',
				{elseif request()->get('email')/}
				search_type:'email',
				key:'{:request()->get('email')}',
				{else/}
				search_type:'id',
				key:'',
				{/notempty}
				ajax:false,
				examine:{:request()->get('examine',"\'all\'")},
				page:1,
				total:0,
				pageSize:10
			},
			tableData:[],
			multipleSelectionIndex:0,
			dialogVisible:false,
			rowData:{},
			top:0,
			recommend:0,
			accumulation:0,
			form:{
				ajax:false,
				status:1,
				notice:1,
				msg:''
			},
	        rules: {
	          status: [
	            { required: true, message: '请选择审核结果', trigger: 'change' },
	          ],
	          msg: [
	            { required: true, message: '请输入审核结果', trigger: 'blur' },
	          ],
	        }
		},
		watch:{
		    view:XYBase.viewWatch,
		},
		created(){
			XYBase.created(this);
		},
	    methods: {
		    toggleSelection(rows) {
		        if (rows) {
		          rows.forEach(row => {
		            this.$refs.tableList.toggleRowSelection(row);
		          });
		        } else {
		          this.$refs.tableList.clearSelection();
		        }
		    },
		    handleSelectionChange(val) {
		        this.multipleSelection = val;
		    },
	      	cancelRefuseWinSubmit(done){
	      		this.rowData={};
	      		this.$refs.form&&this.$refs.form.resetFields();
	      		typeof done==='function'&&done();
				this.dialogVisible=false;
	      	},
			submitForm(formName) {
				var _this=this;
				_this.$refs[formName].validate((valid) => {
				  if (valid) {
				  	if (this.rowData.id) {
					  	_this.setResumeExamine(_this.rowData,_this.form.status);
				  	}else{
						_this.dialogVisible=false;
				  		_this.setResumeExamineALL();
				  	}
				  } else {
					return XYBase.warning('请先把表单填写完整。');
				  }
				});
			},
	    	setResumeDelete(scope){
	    		var _this=this;
		        _this.$confirm('确定恢复《'+scope.row.name+'》简历吗？', '提示', {
		          confirmButtonText: '确定',
		          cancelButtonText: '取消',
		          type: 'warning'
		        }).then(() => {
		    		$.getJSON('/resume/setResumeDelete/'+scope.row.id,function(ret){
		    			if (ret) {
		    				if (ret.code === 0) {
		    					_this.tableData.splice(scope.$index,1);
		    				}else{
		    					XYBase.msg(ret.msg);
		    				}
		    			}else{
							XYBase.error(XYBase.config.system_network_error);
		    			}
		    		});
		        }).catch(() => {
    				XYBase.msg('已取消');
		        });
	    	},
	    	setResumeDeleteForce(scope){
	    		var _this=this;
		        _this.$confirm('确定彻底删除《'+scope.row.name+'》简历吗？', '提示', {
		          confirmButtonText: '确定',
		          cancelButtonText: '取消',
		          type: 'danger'
		        }).then(() => {
		    		$.getJSON('/resume/setResumeDelete/'+scope.row.id+'?force=1',function(ret){
		    			if (ret) {
		    				if (ret.code === 0) {
		    					_this.tableData.splice(scope.$index,1);
		    				}else{
		    					XYBase.msg(ret.msg);
		    				}
		    			}else{
							XYBase.error(XYBase.config.system_network_error);
		    			}
		    		});
		        }).catch(() => {
    				XYBase.msg('已取消');
		        });
	    	},
	    	getSearchType(){
	    		var text='简历ID';
	    		switch(this.search.search_type){
	    			case 'id':
	    				text='简历ID';
	    				break;
	    			case 'uid':
	    				text='UID';
	    				break;
	    			case 'name':
	    				text='姓名';
	    				break;
	    			case 'mobile':
	    				text='手机号';
	    				break;
	    			case 'email':
	    				text='邮箱';
	    				break;
	    		}
	    		return text;
	    	},
			resetForm:function(formName) {
				this.$refs[formName].resetFields();
			},
			handleSizeChange(val) {
				this.search.page=1;
				this.search.pageSize=val;
	          	this.initHtml();
			},
			handleCurrentChange(val) {
				this.search.page=val;
	          	this.initHtml();
			},
	      	initHtml() {
	      		var _this=this;
	      		_this.search.ajax=true;
				$.ajax({
					url:'',
					type:'get',
					data:_this.search,
					dataType:'json',
					error:function(err){
	      				_this.search.ajax=false;
						XYBase.error(XYBase.config.system_network_error);
					},
					success:function(ret){
	      				_this.search.ajax=false;
						if (ret) {
							if (ret.code === 0) {
								_this.search.total=ret.data.total;
								_this.tableData=ret.data.data;
							}else{
								XYBase.msg(ret.msg);
							}
						}else{
							XYBase.error(XYBase.config.system_network_error);
						}
					}
				});
			},
	    }
	});
	$(function(){
		vm.initHtml();
		reloadWindowSize();
		$(window).resize(function(){
			reloadWindowSize();
		});
	});
	function reloadWindowSize (argument) {
		var winW=$(window).width();
		if(winW <= 576){
			vm.labelPosition='top';
		}else{
			vm.labelPosition='right';
		}
	}
</script>
{include file="business"/}
{/block}